﻿using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Coldairarrow.Util.ClassLibrary;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Business.PB
{
    public partial interface IPB_PurchaseBusiness
    {
        Task<PageResult<PB_Purchase>> GetDataListAsync(PageInput<ConditionDTO> input);
        Task<PB_Purchase> GetTheDataAsync(string id);
        Task AddDataAsync(PB_Purchase data);
        Task UpdateDataAsync(PB_Purchase data);
        Task DeleteDataAsync(List<string> ids);

        /// <summary>
        /// 外采订单列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<PB_PurchaseDTO>> GetPurchaseDataListAsync(PageInput<PurchaseConditionDTO> input);

        /// <summary>
        /// 外采到货列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<PB_PurchaseDTO>> GetPurchaseArrivalDataListAsync(PageInput<PurchaseConditionDTO> input);

        /// <summary>
        /// 查看外采订单信息
        /// </summary>
        /// <param name="PurchaseId">外采订单Id</param>
        /// <returns></returns>
        Task<PB_PurchaseDataDTO> GetPurchaseDataAsync(string PurchaseId);

        /// <summary>
        /// 保存外采订单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SavePurchaseDataAsync(PurchaseData data);

        /// <summary>
        /// 审核外采订单
        /// </summary>
        /// <param name="PurchaseId">外采订单Id</param>
        /// <returns></returns>
        Task ToExaminePurchaseDataAsync(string PurchaseId);

        /// <summary>
        /// 获取外采订单明细信息
        /// </summary>
        /// <param name="PurchaseId">外采订单Id</param>
        /// <returns></returns>
        Task<List<PurchasePrintDTO>> GetPurchaseDetailListAsync(string PurchaseId);

        /// <summary>
        /// 外采单确认
        /// </summary>
        /// <param name="PurchaseId"></param>
        /// <returns></returns>
        Task DeterminePurchaseDataAsync(string PurchaseId);

        /// <summary>
        /// 外采订单打码
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <param name="_redisOptions"></param>
        /// <returns></returns>
        Task PrintPurchaseAsync(PurchasePrintData data, MongoDBOptions _mongodbOptions, RedisOptions _redisOptions);

        /// <summary>
        /// 外采订单成品码明细
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<PB_JobBookingQrCodeDTO>> GetPurchaseDetailJobBookingQrCodeAsync(PageInput<PurchaseConditionDTO> input);

        /// <summary>
        /// 外采订单成品物料补打
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task PrintPurchaseJobBookingQrCodeAsync(PurchaseMaterialPrintDataDTO data, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 外采订单包明细
        /// </summary>
        /// <param name="PurchaseId">外采订单Id</param>
        /// <param name="MaterialId">物料Id</param>
        /// <returns></returns>
        Task<List<PurchasePackList>> GetPurchasePackListAsync(string PurchaseId, string MaterialId);

        /// <summary>
        /// 外采订单包码补打
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task PrintPurchasePackListAsync(PurchaseMaterialPrintDataDTO data, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 外采订单签收明细
        /// </summary>
        /// <param name="PurchaseId"></param>
        /// <returns></returns>
        Task<PB_PurchaseDataDTO> GetSurplusPurchaseDetailAsync(string PurchaseId);

        /// <summary>
        /// 外采订单签收
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task UpdatePurchaseDataAsync(PB_PurchaseDataDTO data);

    }

    /// <summary>
    /// 搜索查询条件
    /// </summary>
    public class PurchaseConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }
        public string Status { get; set; }
        public string MaterialId { get; set; }
        public string PurchaseId { get; set; }
    }

    /// <summary>
    /// 外采订单保存DATA
    /// </summary>
    public class PurchaseData
    {
        /// <summary>
        /// 任务单Id
        /// </summary>
        public String Id { get; set; }

        /// <summary>
        /// 外采订单名称
        /// </summary>
        public String Name { get; set; }

        /// <summary>
        /// 外采日期
        /// </summary>
        public DateTime? PurchaseDate { get; set; }

        /// <summary>
        /// 预计交工日期
        /// </summary>
        public DateTime? HandoverDate { get; set; }

        /// <summary>
        /// 客户Id
        /// </summary>
        public String SupplierId { get; set; }

        /// <summary>
        /// 税率
        /// </summary>
        public Double? Rate { get; set; }

        /// <summary>
        /// 总金额
        /// </summary>
        public Double? TotalAmount { get; set; }

        /// <summary>
        /// 总重量
        /// </summary>
        public Double? TotalWeight { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public String Remarks { get; set; }

        /// <summary>
        /// 明细
        /// </summary>
        public List<PurchaseDetailData> PurchaseDetail { get; set; }

    }

    /// <summary>
    /// 外采订单保存明细
    /// </summary>
    public class PurchaseDetailData
    {
        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public Double? Price { get; set; }

        /// <summary>
        /// 金额
        /// </summary>
        public Double? Amount { get; set; }

        /// <summary>
        /// 理论重量
        /// </summary>
        public Double? Weight { get; set; }

        /// <summary>
        /// 总重量
        /// </summary>
        public Double? TotalWeight { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public String Remarks { get; set; } 

    }

    /// <summary>
    /// 查看外采订单信息
    /// </summary>
    public class PB_PurchaseDataDTO : PB_Purchase
    {
        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 仓库名称
        /// </summary>
        public string StorName { get; set; }

        /// <summary>
        /// 外采任务单明细
        /// </summary>
        public List<PurchaseDetailDTO> PurchaseDetail { get; set; }

        /// <summary>
        /// 外采任务单签收剩余明细
        /// </summary>
        public List<SurplusPurchaseDetailDTO> SurplusPurchaseDetail { get; set; }
    }

    /// <summary>
    /// 外采任务单明细
    /// </summary>
    public class PurchaseDetailDTO : PB_PurchaseDetail
    {
        /// <summary>
        /// 物料编号
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 是否序列化
        /// </summary>
        public Boolean? IsNumber { get; set; }

        /// <summary>
        /// 是否成品
        /// </summary>
        public Boolean? IsProduct { get; set; }

        /// <summary>
        /// 没包装数量
        /// </summary>
        public Double? PackageNum { get; set; }

        /// <summary>
        /// 是否为单个物料
        /// </summary>
        public Boolean? IsSingle { get; set; }

    }

    /// <summary>
    /// 外采任务单签收剩余明细
    /// </summary>
    public class SurplusPurchaseDetailDTO
    {
        /// <summary>
        /// 外采订单Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料编号
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public Double? Price { get; set; }

        /// <summary>
        /// 金额
        /// </summary>
        public Double? Amount { get; set; }

        /// <summary>
        /// 理论单重
        /// </summary>
        public Double? Weight { get; set; }

        /// <summary>
        /// 理论总重量
        /// </summary>
        public Double? TotalWeight { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }

        /// <summary>
        /// 外采订单回货的已签收数量
        /// </summary>
        public Double? SignedQuantity { get; set; }

        /// <summary>
        /// 外采订单回货的剩余数量
        /// </summary>
        public Double? Quantity { get; set; }

    }

    /// <summary>
    /// 打码传值
    /// </summary>
    public class PurchasePrintData
    {
        /// <summary>
        /// 外采订单Id
        /// </summary>
        public string PurchaseId { get; set; }

        /// <summary>
        /// 收货单物料明细
        /// </summary>
        public List<string> liststr { get; set; }

    }

    /// <summary>
    /// 外采订单包明细
    /// </summary>
    public class PurchasePackList
    {
        /// <summary>
        /// 包Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 包名称
        /// </summary>
        public string BoxName { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string Spec { get; set; }

        /// <summary>
        /// 物料类型名称
        /// </summary>
        public string MaterialTypeName { get; set; }

        /// <summary>
        /// 二维码
        /// </summary>
        public string QrCode { get; set; }

        /// <summary>
        /// 组织名称
        /// </summary>
        public string DeptName { get; set; }

        /// <summary>
        /// 外采订单id
        /// </summary>
        public string PurchaseId { get; set; }

        /// <summary>
        /// 是否成品
        /// </summary>
        public Boolean? IsProduct { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }
    }

    /// <summary>
    /// 物料码打印传值
    /// </summary>
    public class PurchaseMaterialPrintDataDTO
    {
        /// <summary>
        /// 外采订单Id
        /// </summary>
        public string PurchaseId { get; set; }

        /// <summary>
        /// 流水号集合
        /// </summary>
        public List<string> nums { get; set; }
    }




}